setAppSetting(injectJS);

function setAppSetting(callback){
    chrome.extension.sendRequest({
            method : "getAppSetting"
        }, 
        function(resp){
            var appSetting = resp.data;

            var nodeId = "ex_hidden_app_setting";
            var dataNode = document.getElementById(nodeId);
            if(!dataNode){
                dataNode = document.createElement("input");
                dataNode.id = nodeId;
                dataNode.type = "hidden";
                document.body.appendChild(dataNode);
            }
            dataNode.value = JSON.stringify(appSetting);

            callback();
    });
}

function injectJS(){
    var node = document.createElement('script');
    var raw_url = "override.js?ver=10";
    var url = chrome.extension.getURL(raw_url);
    node.setAttribute('type', 'text/javascript');            
    node.setAttribute('src', url);
    document.getElementsByTagName('head')[0].appendChild(node);             
}
